//
//  LBCarViewController.m
//  LvoeBeen_Imitation
//
//  Created by apple on 17/2/19.
//  Copyright © 2017年 itcast. All rights reserved.
//

#import "LBCarViewController.h"
#import "LBTableViewCell.h"
#import "LBSuperMarketTableViewCell.h"
#import "LBRecieveTableViewCell.h"
#import "LBRemarksTableViewCell.h"
#import "LBDetailsTableViewCell.h"
#import "LBBottomView.h"

@interface LBCarViewController ()<UITableViewDelegate,UITableViewDataSource>


@end

@implementation LBCarViewController

-(instancetype)init{
    self = [super init];
    if (self) {
        [self setupUI];
    }
    return self;
}

-(void)setupUI{
    
    UITableView *tabView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
    
    [self.view addSubview:tabView];
    //布局
    [tabView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.mas_equalTo(self.view);
        make.bottom.mas_equalTo(self.view).mas_offset(-80);
    }];
    
    //数据源/代理
    tabView.dataSource = self;
    tabView.delegate = self;
    
    //自动行高
    tabView.estimatedRowHeight = 10;
    tabView.rowHeight = UITableViewAutomaticDimension;
    
    tabView.sectionFooterHeight = 0;
    tabView.sectionHeaderHeight = 0;
    
    //注册cell
    [tabView registerNib:[UINib nibWithNibName:@"LBDetailsTableViewCell" bundle:nil] forCellReuseIdentifier:@"cellID"];
    
    [tabView registerNib:[UINib nibWithNibName:@"LBTableViewCell" bundle:nil] forCellReuseIdentifier:@"headID"];
    
    [tabView registerNib:[UINib nibWithNibName:@"LBSuperMarketTableViewCell" bundle:nil] forCellReuseIdentifier:@"superID"];
    
    [tabView registerNib:[UINib nibWithNibName:@"LBRecieveTableViewCell" bundle:nil] forCellReuseIdentifier:@"recieveID"];

    [tabView registerNib:[UINib nibWithNibName:@"LBRemarksTableViewCell" bundle:nil] forCellReuseIdentifier:@"remarksID"];
    
    //购物车底部视图
    LBBottomView *bottomView = [LBBottomView bottomView];
    [self.view addSubview:bottomView];
    //布局
    [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.left.right.mas_equalTo(self.view);
        make.top.mas_equalTo(tabView.mas_bottom);
        make.height.mas_equalTo(80);
    }];
    
    //
    
}

#pragma mark
#pragma mark - tableView代理方法
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 5;
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0 || section == 1 || section == 2 || section == 3  ) {
        return 1;
    }else{
        return 5;
    }
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if(indexPath.section == 0){
        
        LBTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"headID"];

        return cell;
    }
    if(indexPath.section == 1){
        
        LBSuperMarketTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"superID"];
        
        return cell;
    }
    if(indexPath.section == 2){
        
        LBRecieveTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"recieveID"];
        
        return cell;
    }
    
    if(indexPath.section == 3){
        
        LBRemarksTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"remarksID"];
        
        return cell;
    }
    
    LBDetailsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellID"];
    
    return cell;
}



@end
